Skip to content

FIX: All-numeric names exceeding Int32.MaxValue no longer throw when generating a unique name [UUM-145766] - #2464

Merged
Pauliusd01 merged 4 commits into
developfrom
fix/uum-145766-makeuniquename-overflow
Aug 5, 2026
Merged

FIX: All-numeric names exceeding Int32.MaxValue no longer throw when generating a unique name [UUM-145766]#2464
Pauliusd01 merged 4 commits into
developfrom
fix/uum-145766-makeuniquename-overflow

Conversation

@Pauliusd01

Copy link
Copy Markdown
Collaborator

Description

Note

This pull request was generated automatically. Please review carefully before merging.

StringHelpers.MakeUniqueName<TExisting>(string baseName, IEnumerable<TExisting> existingSet, Func<TExisting, string> getNameFunc) detects a trailing run of digits on the base name and seeds its counter from that number using int.Parse. When the base name is entirely digits and its value exceeds Int32.MaxValue (for example 451734859173), int.Parse throws an OverflowException. In the Input Actions window this surfaces when adding a control scheme with such a name: the exception aborts naming and the scheme is created with the default "New Control Scheme" instead of the entered name.

The trailing-digit branch now parses with int.TryParse. When the parse fails, the branch is skipped and the full name is kept as the base rather than stripping the digit suffix, so the loop appends a numeric suffix to make the name unique (e.g. a colliding 451734859173 becomes 4517348591731) instead of throwing. Names that fit in Int32 are unaffected.

Testing status & QA

  • No automated test added - the InputSystem test assembly has no existing StringHelpers test file to extend, and the fix is a self-contained guard around a single integer parse.
  • QA can re-run the ticket repro: in the Input Actions window add a control scheme whose name is all digits and larger than Int32.MaxValue (e.g. 451734859173); the scheme should now keep the entered name with no OverflowException in the console, instead of falling back to New Control Scheme. See https://jira.unity3d.com/browse/UUM-145766

Overall Product Risks

  • Complexity: low
  • Halo Effect: low (internal-only edit confined to a single method in StringHelpers; no public API surface touched)
  • Risk rating: 3/5 - MakeUniqueName is called from four sites including InputManager's per-device-add naming path yet has no direct test coverage, so a regression in the reworked digit-suffix branch could land uncaught.

Comments to reviewers

N/A

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

…generating a unique name [UUM-145766]

StringHelpers.MakeUniqueName threw an OverflowException when generating a unique name from an all-numeric base name whose value exceeded Int32.MaxValue, causing the entered control scheme name to be discarded in favour of the default "New Control Scheme".

StringHelpers.MakeUniqueName<TExisting>(string baseName, IEnumerable<TExisting> existingSet, Func<TExisting, string> getNameFunc) parsed the trailing digit run with int.Parse, which overflows for values above Int32.MaxValue. It now uses int.TryParse and, when the parse fails, keeps the full name as the base rather than stripping the digit suffix, so a numeric suffix is appended to make the name unique instead of an exception being thrown.

Jira: https://jira.unity3d.com/browse/UUM-145766
@Pauliusd01 Pauliusd01 self-assigned this Aug 5, 2026
@Pauliusd01
Pauliusd01 marked this pull request as ready for review August 5, 2026 08:06
@Pauliusd01
Pauliusd01 requested a review from K-Tone August 5, 2026 08:07
u-pr[bot]

This comment was marked as resolved.

…ix cannot overflow [UUM-145766]

Guard the collision counter against overflowing when the trailing digits equal Int32.MaxValue.

When an all-numeric base name parsed to exactly Int32.MaxValue, seeding the counter with trailingNumber + 1 overflowed int and the collision loop produced negative suffixes. The counter is now a long and the seeding addition is widened, so the suffix continues past Int32.MaxValue as a positive number.

Jira: https://jira.unity3d.com/browse/UUM-145766
@Pauliusd01

Copy link
Copy Markdown
Collaborator Author

@u-pr made suggested changes, review it again

@u-pr

This comment was marked as resolved.

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs Outdated
@codecov-github-com

codecov-github-com Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2464   +/-   ##
========================================
  Coverage    78.95%   78.95%           
========================================
  Files          767      767           
  Lines       140780   140805   +25     
========================================
+ Hits        111153   111177   +24     
- Misses       29627    29628    +1     
Flag Coverage Δ
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.49% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.49% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.55% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.55% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.7 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.7_project 77.55% <100.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.40% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.40% <100.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.46% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.46% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.7 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.7_project 77.46% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tem/InputSystem/Runtime/Utilities/StringHelpers.cs 68.64% <100.00%> (ø)

... and 2 files with indirect coverage changes

ℹ️ Need help interpreting these results?

…ened counter [UUM-145766]

Parse the trailing numeric suffix as a long so names whose digits exceed Int32.MaxValue seed the counter instead of falling through to the append path.

With namesTried already a long, long.TryParse lets a name like "item2147483648" increment to "item2147483649" on collision, rather than failing int.TryParse and producing "item21474836481". A name is only treated as an unseeded base when its digit run exceeds Int64.MaxValue.

Jira: https://jira.unity3d.com/browse/UUM-145766
…euniquename-overflow

# Conflicts:
#	Packages/com.unity.inputsystem/CHANGELOG.md
@Pauliusd01

Copy link
Copy Markdown
Collaborator Author

@u-pr requested changes added, review it again

@u-pr

u-pr Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The changes look great! Switching to long.TryParse and widening namesTried to long correctly handles numeric names near and above Int32.MaxValue, completely resolving the OverflowException while maintaining sequential naming on collisions.

📚 Additional Context
  • Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/StringHelpers.cs

🤖 Helpful? 👍/👎

@Pauliusd01
Pauliusd01 merged commit 9481632 into develop Aug 5, 2026
64 of 111 checks passed
@Pauliusd01
Pauliusd01 deleted the fix/uum-145766-makeuniquename-overflow branch August 5, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants